<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>新增收货地址</title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link rel="stylesheet" type="text/css" href="../css/index.css"/>
		<link rel="stylesheet" type="text/css" href="../css/style.css"/>
		<script src="../js/vue.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/vant.min.js" type="text/javascript" charset="utf-8"></script>
		<script src="../js/ajax.js" type="text/javascript" charset="utf-8"></script>
		<script src="html5plus://ready"></script>
		<script src="../js/adddizhi.js" type="text/javascript" charset="utf-8"></script>
		<style type="text/css">
			header {
				padding: 15px 20px 5px 20px;
				background-color: red;
				color: white;
				margin-top: 0px;
			}			
			#form-style{
				padding: 0px 10px 0px 10px;
			}
			#row-style{
				padding: 13px;
				margin-top: 5px;
			}
			#button{
				padding: 20px 13px 0px 13px;
			}
			#urlstyle{
				padding: 5px 5px 5px 15px;
				color: #1989FA;
			}
		</style>
	</head>

	<body>
		<div id="app">
			<header>
				<van-row>
					<van-col span="4" >
						<span @click="goBack"><返回</span>
					</van-col>
							<van-col span="17">新增收货地址</van-col>
							<van-col span="3"></van-col>
				</van-row>
			</header>
			<!--头部结束-->

			<section>
				<div id="form-style"><!--上边表单部分开始-->
					<van-field  label="姓名" placeholder="收人姓名" v-model="name"></van-field>
					<van-field  label="电话" placeholder="收货人手机号" v-model="phone"></van-field>
					<van-field  label="地区" placeholder="请输入收货地区编号" v-model="region"></van-field>
					<div id="urlstyle" >
						<span @click="inquier">点击查询地区编号</span>
					</div>
					<van-field  label="详细地址" placeholder="街道门牌、楼层房间号等信息" v-model="detalregion"></van-field>	
					<van-row id="row-style">
						<van-col span="20">设为默认收货地址</van-col>
						<van-col span="4"><van-switch v-model="checked" ></van-switch></van-col>
					</van-row>					
				</div>
				<!--上边表单部分结束-->
				
				<div id="button"><!--控制按钮样式-->
					<van-button type="danger" size="large" @click="save">保存</van-button>					
				</div>
			</section>

		</div>
		<script type="text/javascript">
			
			var vm = new Vue({
				el: "#app",
				data: {
					checked:false,
					name:"",
					phone:"",
					region:"",
					detalregion:"",
					key:localStorage.getItem("keys")
				},
				methods:{
					inquier(){
						plus.webview.create("code.html","code");
						plus.webview.show("code","slide-in-right");
					},
					goBack(){
						var arr=plus.webview.currentWebview();
						
						plus.webview.close(arr,"slide-out-right");
						var user=plus.webview.getWebviewById("shipping");//返回时刷新列表 
						user.reload(true);//刷新列表页面						
					},
					save(){
						ajax({
							url:"http://dsapi.ysd3g.com/API/AddShippingAddress",
							data:{
								key:vm.key,
								name:vm.name,
								phone:vm.phone,
								districtCode:vm.region,
								address:vm.detalregion,
								isdefault:vm.checked
							},
							dataType:"jsonp",
							success: function(res) {								
								if (res.Error == false) {
									vm.$toast.success("添加地址成功");
								} else {
									vm.$toast.fail(res.Msg);
								}
							}
						})
					}
				}
			})
		</script>
	</body>

</html>